write a function hackerrank solution

visit shbcf.ru